package com.beaut.project.service;


import java.util.Arrays;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.beaut.project.dao.OaMapper;
import com.beaut.project.util.StaticData;
import com.beaut.project.util.Utility;

@Transactional(rollbackFor = Exception.class)
@Service("oaService")
public class OaService {
	@Autowired
	private OaMapper oaMapper;
	
	public String listPageLeave(Map<String,Object> map){
		List<Map<String,Object>> list= oaMapper.listPageLeave(map);
		for(int i=0;i<list.size();i++){
			list.get(i).put("status_desc", StaticData.ADUIT_STATUS.get(String.valueOf(list.get(i).get("status"))));
		}
		StringBuffer sb = new StringBuffer("");
		sb.append(Utility.lstMaptoJson(list));
		Utility.putSuccess(map);
		return sb.toString();
	}
	
	public String getLeaveById(Map<String,Object> map){
		return Utility.toJson(oaMapper.getLeaveById(map));
	}
	public String addLeave(Map<String,Object> map){
		oaMapper.addLeave(map);
		return Utility.rtJson(Utility.RETURN_OK, "添加成功", null);
	}
	public String updateLeave(Map<String,Object> map){
		oaMapper.updateLeave(map);
		return Utility.rtJson(Utility.RETURN_OK, "更新成功", null);
	}
	public String deleteLeave(Map<String,Object> map){
		oaMapper.deleteLeave(map);
		return Utility.rtJson(Utility.RETURN_OK, "删除成功", null);
	}
}
